
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>
        X-admin v1.0
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../static/css/x-admin.css" media="all">
    <link rel="stylesheet" href="../static/css/dj-css.css" media="all">
</head>

<body>
<div class="x-body" style="padding: 0;">
    <div id="addNews" class="addNews">
        <fieldset class="layui-elem-field layui-field-title" >
            <legend>问卷</legend>
        </fieldset>
    <form class="layui-form layui-form-pane" method="post" action="" >
        <input type="hidden" name="id" v-model="id">
        <div class="layui-form-item">
            <label for="name" class="layui-form-label">
               问卷名称
            </label>
            <div class="layui-input-inline">
                <input type="text" id="name" name="name" v-model="name"  required="" lay-verify="required"
                       autocomplete="off" placeholder="请输入问卷名称" class="layui-input" value="">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red" style="font-size: 14px;">*必填</span>
            </div>
        </div>


        <div class="layui-form-item">
            <label for="description" class="layui-form-label">
                问卷描述
            </label>
            <div class="layui-input-inline">
                <input type="text" id="description" name="description" v-model="description"  lay-verify="required" placeholder="请输入问卷描述" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red" style="font-size: 14px;">*必填</span>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn"  lay-submit="" lay-filter="edit">提交</button>
            </div>
        </div>
    </form>

    </div>
</div>
<script src="../static/lib/jquery.min.js"></script>
<script src="../static/lib/vue.min.js"></script>
<script src="../static/lib/layui/layui.js" charset="utf-8"></script>
<script src="../static/lib/x-layui.js" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8" src="../static/lib/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="../static/lib/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="../static/lib/ueditor/lang/zh-cn/zh-cn.js"></script>
<script src="../static/lib/dj-js.js"></script>
<script>
    var VM = new Vue({
        el:"#addNews",
        data:{
            id:'$map.data.id',
            name:'$map.data.name',
            description:'$map.data.description',
            msg:'成功',
        },
        created:function(){
        },
        watch:{
        },
        mounted:function(){
        },
        methods:{
            submits:function () {
                var _this = this;
                $.ajax({
                    url:"../qsquestion/save.do",
                    dataType:"json",
                    data:{
                        id:_this.id,
                        name:_this.name,
                        description:_this.description,
                    },
                    type:"POST",
                    async:false,
                    success:function (res) {
                        if(res.msg=="success"){
                            layer.alert("编辑成功", {icon: 6},function () {
                                // 获得frame索引
                                var index = parent.layer.getFrameIndex(window.name);
                                //关闭当前frame
                                parent.location.reload();
                                parent.layer.close(index);

                            });
                        }else{
                            layer.msg("增加失败", {icon: 1});
                        }
                    },
                    error:function (XMLHttpRequest) {
                        layer.msg("系统错误", {icon: 1});
                    }
                })

                return false;
            }

        }
    });

    layui.use(['form','layer','upload'], function(){
        $ = layui.jquery;
        var form = layui.form()
                ,layer = layui.layer;
        form.verify({

        });
        form.on('submit(edit)', function(data) {
            var _this = VM;
            $.ajax({
                url: "../qsquestion/save.do",
                dataType: "json",
                data: {
                    id: _this.id,
                    name: _this.name,
                    description: _this.description,
                },
                type: "POST",
                async: false,
                success: function (res) {
                    if (res.msg == "success") {
//                        layer.alert("编辑成功", {icon: 6}, function () {
                            // 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.location.reload();
                            parent.layer.close(index);

//                        });
                    } else {
                        layer.msg("增加失败", {icon: 1});
                    }
                },
                error: function (XMLHttpRequest) {
                    layer.msg("系统错误", {icon: 1});
                }
            })

            return false;
        })
    });
</script>
</body>

</html>
